<?php
/*
 * @Descripttion:
 * @version:
 * @Author: sueRimn
 * @Date: 2020-06-22 19:08:08
 * @LastEditors: sueRimn
 * @LastEditTime: 2020-06-22 22:39:15
 */
    //用户收货地址列表
    require_once "config.php";
    require_once "weixin_info.php";
    $sql = $mysql->query("select * from dyspw_mem_address where  uid = {$_SESSION['Member_info'][0]['id']} ");
    $address_list = $sql->fetch_all(MYSQLI_ASSOC);
    if(empty($address_list)){
        $info = '您暂未添加收货地址';
    }
 ?>

 <!DOCTYPE html>
 <html lang="en">
 <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>管理收货地址</title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet" />
    <link href="css/index.css" rel="stylesheet" />
    <link rel="stylesheet" href="css/core.css">
 </head>
 <body>
    <section class="address-list-box">
        <header id="header" class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">管理收货地址</h1>
		</header>
        <ul class="mui-table-view">
            <?php foreach ($address_list as $key => $val) { ?>
                <li class="mui-table-view-cell address-list-item">
                    <div class="address-item-left">
                        <p class="address-item-left-primary"><?php echo $val['add_place'] ?></p>
                        <p class="address-item-left-vice"><?php echo $val['add_link'] ?>（ <?php if($val['add_sex'] == 1){echo '先生';}else{echo '女士';} ?>    ） <?php echo $val['add_mobile'] ?>  </p>
                    </div>
                    <div class="address-item-right">
                        <a href="javascript:void(0);" class="mui-icon mui-icon-trash deleteAddress" data_id="<?php echo $val['id']; ?>"></a>
                        <a href="address_edit.php?id=<?php echo $val['id']; ?>" class="mui-icon mui-icon-compose"></a>
                    </div>
                </li>
            <?php } ?>
        </ul>
        <a class="address-list-addbtn" href="./address_edit.php">新增收货地址</a>
    </section>
 </body>
 <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
 <script type="text/javascript">
    $(function () {
        mui.init();
        $('.mui-table-view').on('tap', '.deleteAddress', function() {
            var btnArray = ['取消', '确认'];
            var _this = $(this);
            var id = _this.attr("data_id");
            mui.confirm('此操作将删除当前地址，确认？', '确认信息', btnArray, function(e) {
                if (e.index == 1) {
                    $.ajax({
                        url: 'address_ajax.php',
                        type: "post",
                        data: {'id':id,'mold':'delete'} ,
                        dataType: 'json',
                        success:function(res){
                            console.log(res);
                            if(res.status == 'y'){
                                mui.alert(res.info);
                                window.location.href = "address_list.php";
                            }else{
                                layer.open({content: res.info,skin: 'msg',time: 2 });
                            }
                        }
                    })
                } else {
                }
            })
        })
    });
 </script>
 </html>
